#include <assert.h>
#include "scene.h"
#include "ctrlboard.h"
#include "mg_Lcd_Driver.h"
#include "mg_Device.h"
#include "mg_Rs485Protocol.h"
#include "mg_Rotate.h"

/* widgets:
Layer_MainMenu3
Background_Mainmenu3
Container_Hint
Text_Hint2
Text_Hint1
CoverFlow_Mainmenu3
Container_MM3_virtual_Config
Container_MM3_virtual29
Container_MM3_virtual28
Container_MM3_virtual27
Container_MM3_virtual26
Container_MM3_virtual25
Container_MM3_virtual24
Container_MM3_virtual23
Container_MM3_virtual22
Container_MM3_virtual21
Container_MM3_virtual20
Container_MM3_virtual19
Container_MM3_virtual18
Container_MM3_virtual17
Container_MM3_virtual16
Container_MM3_virtual15
Container_MM3_virtual14
Container_MM3_virtual13
Container_MM3_virtual12
Container_MM3_virtual11
Container_MM3_virtual10
Container_MM3_virtual9
Container_MM3_virtual8
Container_MM3_virtual7
Container_MM3_virtual6
Container_MM3_virtual5
Icon54
Container_MM3_virtual4
Icon53
Container_MM3_virtual3
Icon52
Container_MM3_virtual2
Icon51
Container_MM3_virtual1
Icon50
Container_MM3_virtual0
Icon38
*/
//更新图标和文字的位子及透明度
void Update_PopButton_Position(void);

static ITUBackground* Background_Mainmenu3;
static ITUCoverFlow* CoverFlow_Mainmenu3;
static ITUContainer* Container_MainMenu3_Config, *Container_MM3_virtual_Config;
static ITUContainer* Container_MM3_virtual[DeviceNumMax];
static ITUContainer* Container_MainMenu3[DeviceNumMax];
static ITUPopupButton* PopupButton_MainMenu3[DeviceNumMax];
static ITUText* Text_MM3_Name1[DeviceNumMax];
static ITUText* Text_MM3_Name2[DeviceNumMax];
static ITUText* Text_MM3_State[DeviceNumMax];
static ITUText* Text_MM3_Page[DeviceNumMax];
static ITUText* Text_MM3_Setting;
static bool Is_HaveDevice = false;
bool MainMenu3OnEnter(ITUWidget* widget, char* param)
{
	uint8_t i, PageNum_D = 0;
	char PageNum[3], Page[10];
	char DeviceState_Text[20];
	char TempName[64], TempNum[64];
	UTF8_TWO_LINE DeviceTempName;
	if (!Background_Mainmenu3)
	{
		Background_Mainmenu3 = ituSceneFindWidget(&theScene, "Background_Mainmenu3");
		assert(Background_Mainmenu3);
		CoverFlow_Mainmenu3 = ituSceneFindWidget(&theScene, "CoverFlow_Mainmenu3");
		assert(CoverFlow_Mainmenu3);
		Container_MainMenu3_Config = ituSceneFindWidget(&theScene, "Container_MainMenu3_Config");
		assert(Container_MainMenu3_Config);
		Container_MM3_virtual_Config = ituSceneFindWidget(&theScene, "Container_MM3_virtual_Config");
		assert(Container_MM3_virtual_Config);
		for (i = 0; i < DeviceNumMax; i++)//加载小部件
		{
			//Container
			strcpy(TempName, "Container_MainMenu3_");
			strcat(TempName, itoa(i, TempNum, 10));
			Container_MainMenu3[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Container_MainMenu3[i]);
			strcpy(TempName, "Container_MM3_virtual");
			strcat(TempName, itoa(i, TempNum, 10));
			Container_MM3_virtual[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Container_MM3_virtual[i]);
			//PopupButton
			strcpy(TempName, "PopupButton_MainMenu3_");
			strcat(TempName, itoa(i, TempNum, 10));
			PopupButton_MainMenu3[i] = ituSceneFindWidget(&theScene, TempName);
			assert(PopupButton_MainMenu3[i]);
			//Text_MM_Name1
			strcpy(TempName, "Text_MM3_Name1_");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM3_Name1[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM3_Name1[i]);
			//Text_MM_Name2
			strcpy(TempName, "Text_MM3_Name2_");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM3_Name2[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM3_Name2[i]);
			//Text_MM_State
			strcpy(TempName, "Text_MM3_State");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM3_State[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM3_State[i]);
			//Text_MM_Page
			strcpy(TempName, "Text_MM3_Page");
			strcat(TempName, itoa(i, TempNum, 10));
			Text_MM3_Page[i] = ituSceneFindWidget(&theScene, TempName);
			assert(Text_MM3_Page[i]);
		}
		Text_MM3_Setting = ituSceneFindWidget(&theScene, "Text_MM3_Setting");
		assert(Text_MM3_Setting);
	}
	ituWidgetSetVisible(CoverFlow_Mainmenu3, false);//设置为隐藏
	for (i = 1; i <= DeviceNumMax; i++)//获取总页数
	{
		if (TFT_Device[i].DeviceIsAllocation == true)
			PageNum_D++;
	}
	itoa(PageNum_D, PageNum, 10);//将总页数转成字符串
	//对每个按键进行编辑
	Is_HaveDevice = false;
	PageNum_D = 0;//页码归零
	for (i = 1; i <= DeviceNumMax; i++)
	{
		if (Sys.Language == MG_LANGUAGE_CHS)
		{
			Text_MM3_Name1[i - 1]->fontIndex = 5;
			Text_MM3_Name1[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM3_Name1[i - 1], 30);
			ituWidgetSetY(Text_MM3_Name1[i - 1], 84);
			Text_MM3_Name2[i - 1]->fontIndex = 5;
			Text_MM3_Name2[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM3_Name2[i - 1], 30);
			ituWidgetSetY(Text_MM3_Name2[i - 1], 116);
			Text_MM3_State[i - 1]->fontIndex = 1;
			Text_MM3_State[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM3_State[i - 1], 19);
			ituWidgetSetY(Text_MM3_State[i - 1], 46);
			Text_MM3_Page[i - 1]->fontIndex = 1;
			Text_MM3_Page[i - 1]->boldSize = 1;
			ituTextSetFontSize(Text_MM3_Page[i - 1], 15);
			ituWidgetSetY(Text_MM3_Page[i - 1], 164);
		}
		else if (Sys.Language == MG_LANGUAGE_ENG)
		{
			Text_MM3_Name1[i - 1]->fontIndex = 4;
			Text_MM3_Name1[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Name1[i - 1], 22);
			ituWidgetSetY(Text_MM3_Name1[i - 1], 88);
			Text_MM3_Name2[i - 1]->fontIndex = 4;
			Text_MM3_Name2[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Name2[i - 1], 22);
			ituWidgetSetY(Text_MM3_Name2[i - 1], 112);
			Text_MM3_State[i - 1]->fontIndex = 7;
			Text_MM3_State[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_State[i - 1], 15);
			ituWidgetSetY(Text_MM3_State[i - 1], 50);
			Text_MM3_Page[i - 1]->fontIndex = 7;
			Text_MM3_Page[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_State[i - 1], 15);
			ituWidgetSetY(Text_MM3_Page[i - 1], 160);
		}
		else if (Sys.Language == MG_LANGUAGE_ZHTW)
		{
			Text_MM3_Name1[i - 1]->fontIndex = 8;
			Text_MM3_Name1[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Name1[i - 1], 24);
			ituWidgetSetY(Text_MM3_Name1[i - 1], 84);
			Text_MM3_Name2[i - 1]->fontIndex = 8;
			Text_MM3_Name2[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Name2[i - 1], 24);
			ituWidgetSetY(Text_MM3_Name2[i - 1], 116);
			Text_MM3_State[i - 1]->fontIndex = 8;
			Text_MM3_State[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_State[i - 1], 12);
			ituWidgetSetY(Text_MM3_State[i - 1], 46);
			Text_MM3_Page[i - 1]->fontIndex = 8;
			Text_MM3_Page[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Page[i - 1], 12);
			ituWidgetSetY(Text_MM3_Page[i - 1], 164);
		}
		if (TFT_Device[i].DeviceIsAllocation == true)
		{
			Is_HaveDevice = true;
			PageNum_D++;
			printf("Device No.%d : \n", i);
			//设备是否显示
			ituWidgetSetVisible(Container_MM3_virtual[i - 1], true);//设置为显示
			if (TFT_Device[i].DeviceEventType == 1)//设备名称拆解
				DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Device.DeviceNameLen);//获取合理的换行字符串
			else//场景名称拆解
				DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceNameLen);//获取合理的换行字符串
			ituTextSetString(Text_MM3_Name1[i - 1], DeviceTempName.DeviceName1);
			ituTextSetString(Text_MM3_Name2[i - 1], DeviceTempName.DeviceName2);
			if (strlen(DeviceTempName.DeviceName2) == 0)//单行字母
			{
				if (Sys.Language == MG_LANGUAGE_CHS)
					ituWidgetSetY(Text_MM3_Name1[i - 1], 96);
				else if (Sys.Language == MG_LANGUAGE_ENG)
					ituWidgetSetY(Text_MM3_Name1[i - 1], 100);
			}
			printf("Name : %s\n", TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName);
			//设备状态显示
			GetText_DeviceState(i, DeviceState_Text);
			ituTextSetString(Text_MM3_State[i - 1], DeviceState_Text);
			printf("State : %s\n", DeviceState_Text);
			//页码显示
			itoa(PageNum_D, Page, 10);
			strcat(Page, "/");
			strcat(Page, PageNum);
			ituTextSetString(Text_MM3_Page[i - 1], Page);
			printf("Page : %s\n", Page);
		}
		else
		{
			printf("Device No.%d is not exist! \n", i);
			ituWidgetSetVisible(Container_MM3_virtual[i - 1], false);//设置为隐藏
		}
	}
	if (Is_HaveDevice == false)//没有设备
	{
		ituWidgetSetVisible(Container_MM3_virtual[0], true);//设置为显示
		ituTextSetString(Text_MM3_State[0], "");
		if (Sys.Language == MG_LANGUAGE_CHS)
		{
			ituTextSetString(Text_MM3_Name1[0], "暂未");
			ituTextSetString(Text_MM3_Name2[0], "配置");
		}
		else if (Sys.Language == MG_LANGUAGE_ENG)
		{
			ituTextSetString(Text_MM3_Name1[0], "Not");
			ituTextSetString(Text_MM3_Name2[0], "configured");
		}
		else if (Sys.Language == MG_LANGUAGE_ZHTW)
		{
			ituTextSetString(Text_MM3_Name1[0], "暫未");
			ituTextSetString(Text_MM3_Name2[0], "配置");
		}
		ituTextSetString(Text_MM3_Page[0], "1/1");
		ituCoverFlowGoto(CoverFlow_Mainmenu3, 0);
	}
	Update_PopButton_Position();//对所有Button进行位子重设
	if (Sys.Language == MG_LANGUAGE_CHS)
	{
		Text_MM3_Setting->fontIndex = 5;
		Text_MM3_Setting->boldSize = 1;
		ituTextSetFontSize(Text_MM3_Setting, 25);
		ituWidgetSetY(Text_MM3_Setting, 100);
		ituWidgetSetX(Text_MM3_Setting, 69);
	}
	else if (Sys.Language == MG_LANGUAGE_ENG)
	{
		Text_MM3_Setting->fontIndex = 4;
		Text_MM3_Setting->boldSize = 0;
		ituTextSetFontSize(Text_MM3_Setting, 22);
		ituWidgetSetY(Text_MM3_Setting, 102);
		ituWidgetSetX(Text_MM3_Setting, 67);
	}
	else if (Sys.Language == MG_LANGUAGE_ZHTW)
	{
		Text_MM3_Setting->fontIndex = 8;
		Text_MM3_Setting->boldSize = 0;
		ituTextSetFontSize(Text_MM3_Setting, 24);
		ituWidgetSetY(Text_MM3_Setting, 103);
		ituWidgetSetX(Text_MM3_Setting, 68);
	}
	ituWidgetSetVisible(CoverFlow_Mainmenu3, true);//设置为显示
	ituWidgetSetVisible(Background_Mainmenu3, true);//设置为显示
	Set_Rotate_Block(120);//设置间隔刻度
    return true;
}

bool MainMenu3OnLeave(ITUWidget* widget, char* param)
{
	ituWidgetSetVisible(Background_Mainmenu3, false);//设置为隐藏
    return true;
}

bool MainMenu3OnTimer(ITUWidget* widget, char* param)
{
	static uint8_t TempIndex = 1;
	uint8_t i, PageNum_D = 0;
	char PageNum[3], Page[10];
	char DeviceState_Text[20];
	UTF8_TWO_LINE DeviceTempName;
	//用户操作
	if (Action_Cmd.User_Action == Left_Slide || Action_Cmd.User_Action == Anticlockwise_Rotation)
	{
		if (CoverFlowCheckIdle(CoverFlow_Mainmenu3))
		{
			ituCoverFlowPrev(CoverFlow_Mainmenu3);
		}
		Clear_User_Action();
	}
	else if (Action_Cmd.User_Action == Right_Slide || Action_Cmd.User_Action == Clockwise_Rotation)
	{
		if (CoverFlowCheckIdle(CoverFlow_Mainmenu3))
		{
			ituCoverFlowNext(CoverFlow_Mainmenu3);
		}
		Clear_User_Action();
	}
	//滑动检查，获取当前界面状态
	DisplayValue.TFT_Display_Device = CoverFlow_Mainmenu3->focusIndex + 1;
	if (DisplayValue.TFT_Display_Device != TempIndex)
	{
		MessageFlag[MSG_GET_DEVICE_STATE] = ON;
		MessageFlag[MSG_GET_DEVICE_CONFIG] = ON;
		TempIndex = DisplayValue.TFT_Display_Device;
	}
	//设备具体状态显示
	if (MessageFlag[MSG_GUI_STATE_UPDATE] == ON)
	{
		for (i = 1; i <= DeviceNumMax; i++)
		{
			if (TFT_Device[i].DeviceIsAllocation == true)
			{
				//设备状态显示
				GetText_DeviceState(i, DeviceState_Text);
				ituTextSetString(Text_MM3_State[i - 1], DeviceState_Text);
			}
		}
		MessageFlag[MSG_GUI_STATE_UPDATE] = OFF;
	}
	//设备具体状态显示
	if (MessageFlag[MSG_GUI_CONFIG_UPDATE] == ON)
	{
		ituWidgetSetVisible(CoverFlow_Mainmenu3, false);//设置为隐藏
		PageNum_D = 0;
		for (i = 1; i <= DeviceNumMax; i++)//获取总页数
		{
			if (TFT_Device[i].DeviceIsAllocation == true)
				PageNum_D++;
		}
		itoa(PageNum_D, PageNum, 10);//将总页数转成字符串

		//对每个按键进行编辑
		Is_HaveDevice = false;
		PageNum_D = 0;//页码归零
		for (i = 1; i <= DeviceNumMax; i++)
		{
			if (Sys.Language == MG_LANGUAGE_CHS)
			{
				Text_MM3_Name1[i - 1]->fontIndex = 5;
				Text_MM3_Name1[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM3_Name1[i - 1], 30);
				ituWidgetSetY(Text_MM3_Name1[i - 1], 84);
				Text_MM3_Name2[i - 1]->fontIndex = 5;
				Text_MM3_Name2[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM3_Name2[i - 1], 30);
				ituWidgetSetY(Text_MM3_Name2[i - 1], 116);
				Text_MM3_State[i - 1]->fontIndex = 1;
				Text_MM3_State[i - 1]->boldSize = 1;
				ituTextSetFontSize(Text_MM3_State[i - 1], 19);
				ituWidgetSetY(Text_MM3_State[i - 1], 46);
				Text_MM3_Page[i - 1]->fontIndex = 1;
				Text_MM3_Page[i - 1]->boldSize = 1;
				ituWidgetSetY(Text_MM3_Page[i - 1], 164);
			}
			else if (Sys.Language == MG_LANGUAGE_ENG)
			{
				Text_MM3_Name1[i - 1]->fontIndex = 4;
				Text_MM3_Name1[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM3_Name1[i - 1], 22);
				ituWidgetSetY(Text_MM3_Name1[i - 1], 88);
				Text_MM3_Name2[i - 1]->fontIndex = 4;
				Text_MM3_Name2[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM3_Name2[i - 1], 22);
				ituWidgetSetY(Text_MM3_Name2[i - 1], 112);
				Text_MM3_State[i - 1]->fontIndex = 7;
				Text_MM3_State[i - 1]->boldSize = 0;
				ituTextSetFontSize(Text_MM3_State[i - 1], 15);
				ituWidgetSetY(Text_MM3_State[i - 1], 50);
				Text_MM3_Page[i - 1]->fontIndex = 7;
				Text_MM3_Page[i - 1]->boldSize = 0;
				ituWidgetSetY(Text_MM3_Page[i - 1], 160);
			}
		else if (Sys.Language == MG_LANGUAGE_ZHTW)
		{
			Text_MM3_Name1[i - 1]->fontIndex = 8;
			Text_MM3_Name1[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Name1[i - 1], 24);
			ituWidgetSetY(Text_MM3_Name1[i - 1], 84);
			Text_MM3_Name2[i - 1]->fontIndex = 8;
			Text_MM3_Name2[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Name2[i - 1], 24);
			ituWidgetSetY(Text_MM3_Name2[i - 1], 116);
			Text_MM3_State[i - 1]->fontIndex = 8;
			Text_MM3_State[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_State[i - 1], 12);
			ituWidgetSetY(Text_MM3_State[i - 1], 46);
			Text_MM3_Page[i - 1]->fontIndex = 8;
			Text_MM3_Page[i - 1]->boldSize = 0;
			ituTextSetFontSize(Text_MM3_Page[i - 1], 12);
			ituWidgetSetY(Text_MM3_Page[i - 1], 164);
		}
			if (TFT_Device[i].DeviceIsAllocation == true)
			{
				Is_HaveDevice = true;
				PageNum_D++;
				ituWidgetSetVisible(Container_MM3_virtual[i - 1], true);//设置为显示
				if (TFT_Device[i].DeviceEventType == 1)//设备名称拆解
					DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Device.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Device.DeviceNameLen);//获取合理的换行字符串
				else//场景名称拆解
					DeviceTempName = Get_UTF8_Two_Line(TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceName, TFT_Device[i].TFTSCEQ.TFT_Scene.DeviceNameLen);//获取合理的换行字符串
				ituTextSetString(Text_MM3_Name1[i - 1], DeviceTempName.DeviceName1);
				ituTextSetString(Text_MM3_Name2[i - 1], DeviceTempName.DeviceName2);
				if (strlen(DeviceTempName.DeviceName2) == 0)//单行字母
				{
					if (Sys.Language == MG_LANGUAGE_CHS)
						ituWidgetSetY(Text_MM3_Name1[i - 1], 96);
					else if (Sys.Language == MG_LANGUAGE_ENG)
						ituWidgetSetY(Text_MM3_Name1[i - 1], 100);
				}
				//设备状态显示
				ituTextSetString(Text_MM3_State[i - 1], "");
				//页码显示
				itoa(PageNum_D, Page, 10);
				strcat(Page, "/");
				strcat(Page, PageNum);
				ituTextSetString(Text_MM3_Page[i - 1], Page);
			}
			else
				ituWidgetSetVisible(Container_MM3_virtual[i - 1], false);//设置为显示
		}
		if (Is_HaveDevice == false)//没有设备
		{
			ituWidgetSetVisible(Container_MM3_virtual[0], true);//设置为显示
			ituTextSetString(Text_MM3_State[0], "");
			if (Sys.Language == MG_LANGUAGE_CHS)
			{
				ituTextSetString(Text_MM3_Name1[0], "暂未");
				ituTextSetString(Text_MM3_Name2[0], "配置");
			}
			else if (Sys.Language == MG_LANGUAGE_ENG)
			{
				ituTextSetString(Text_MM3_Name1[0], "Not");
				ituTextSetString(Text_MM3_Name2[0], "configured");
			}
			else if (Sys.Language == MG_LANGUAGE_ZHTW)
			{
				ituTextSetString(Text_MM3_Name1[0], "暫未");
				ituTextSetString(Text_MM3_Name2[0], "配置");
			}
			ituTextSetString(Text_MM3_Page[0], "1/1");
			ituCoverFlowGoto(CoverFlow_Mainmenu3, 0);
		}
		ituWidgetSetVisible(CoverFlow_Mainmenu3, true);//设置为显示
		MessageFlag[MSG_GUI_CONFIG_UPDATE] = OFF;
	}
	//更新Button位子
	Update_PopButton_Position();
	//进入测试模式
	if (MessageFlag[MSG_HARDWARE_TEST] == ON)
	{
		MessageFlag[MSG_HARDWARE_TEST] = OFF;
		ITULayer* Layer_TouchTest = ituSceneFindWidget(&theScene, "Layer_TouchTest");
		assert(Layer_TouchTest);
		ituLayerGoto(Layer_TouchTest);
	}
	//切换彩单类型
	if (MessageFlag[MSG_GUI_SWITCH_MAINMENU] == ON)
	{
		MessageFlag[MSG_GUI_SWITCH_MAINMENU] = OFF;
		GotoMainMenu();
	}
    return true;
}

//更新图标和文字的位子及透明度
void Update_PopButton_Position(void)
{
	int RespaceX = 0;
	uint16_t i;
	//计算每个按键的坐标和透明度
	for (i = 0; i < DeviceNumMax; i++)
	{
		//判断是否显示
		if (ituWidgetIsVisible(Container_MM3_virtual[i]))//虚拟coverflow显示
		{
			if (!ituWidgetIsVisible(Container_MainMenu3[i]))
				ituWidgetSetVisible(Container_MainMenu3[i], true);//设置为显示
			RespaceX = ituWidgetGetX(Container_MM3_virtual[i]);//获取虚拟coverflow的X坐标
			if (RespaceX >= 30 && RespaceX <= 90)//中线区域移动
			{
				ituWidgetSetAlphaImpl(Container_MainMenu3[i], 255);
				ituWidgetToBottom(Container_MainMenu3[i]);
			}
			else if (RespaceX >= -120 && RespaceX < 30)
			{
				ituWidgetSetAlphaImpl(Container_MainMenu3[i], (120 + RespaceX) * 255 / 150);
			}
			else if (RespaceX <= 240 && RespaceX >90)
			{
				ituWidgetSetAlphaImpl(Container_MainMenu3[i], (240 - RespaceX) * 255 / 150);
			}
			else
			{
				ituWidgetSetAlphaImpl(Container_MainMenu3[i], 0);
			}
			ituWidgetSetX(Container_MainMenu3[i], RespaceX - 28);
		}
		else
		{
			if (ituWidgetIsVisible(Container_MainMenu3[i]))
				ituWidgetSetVisible(Container_MainMenu3[i], false);//设置为隐藏
		}
		
	}

	//设置界面
	RespaceX = ituWidgetGetX(Container_MM3_virtual_Config);
	if (RespaceX >= 30 && RespaceX <= 90)
	{
		ituWidgetSetAlphaImpl(Container_MainMenu3_Config, 255);
		ituWidgetToBottom(Container_MainMenu3_Config);
	}
	else if (RespaceX >= -120 && RespaceX < 30)
	{
		ituWidgetSetAlphaImpl(Container_MainMenu3_Config, (120 + RespaceX) * 255 / 150);
	}
	else if (RespaceX <= 240 && RespaceX >90)
	{
		ituWidgetSetAlphaImpl(Container_MainMenu3_Config, (240 - RespaceX) * 255 / 150);
	}
	else
	{
		ituWidgetSetAlphaImpl(Container_MainMenu3_Config, 0);
	}
	ituWidgetSetX(Container_MainMenu3_Config, RespaceX - 28);
}
